﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EFGhh.chapater3.Model;

namespace EFGhh.chapater3
{
    public partial class Index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                using (FAQDBEntities db = new FAQDBEntities())
                {
                    rp_biao.DataSource = db.Topics.ToList();
                    rp_biao.DataBind();
                }
            }
        }

        protected void btnSer_Click(object sender, EventArgs e)
        {
            string name = first.Text;
            using (FAQDBEntities db = new FAQDBEntities())
            {
                rp_biao.DataSource = db.Topics.Where(t => t.Title.Contains(name)).ToList();
                rp_biao.DataBind();
            }
        }

        protected void AskQue_Click(object sender, EventArgs e)
        {
            Response.Redirect("Insert.aspx");
        }
    }
}